<template>
	<view class="p_content">
		<view class="p_tips">请选择发布类型</view>
		<view class="p_list" @tap="toPublishHouse">
			<view class="p_list_inner">
				<image class="p_img" src="../../static/img/house_icon.png" mode=""></image>
				<text class="p_text">房屋租售</text>
			</view>
			<view class="select_left">
				<image class="to_arrow" src="../../static/img/right.png" mode=""></image>
			</view>
		</view>
		<view class="p_list" @tap="toZhaopin">
			<view class="p_list_inner">
				<image class="p_img" src="../../static/img/job_icon1.png" mode=""></image>
				<text class="p_text">招聘</text>
			</view>
			<view class="select_left">
				<image class="to_arrow" src="../../static/img/right.png" mode=""></image>
			</view>
		</view>
		<view class="p_list" @tap="toApplyJob">
			<view class="p_list_inner">
				<image class="p_img" src="../../static/img/job_icon.png" mode=""></image>
				<text class="p_text">求职</text>
			</view>
			<view class="select_left">
				<image class="to_arrow" src="../../static/img/right.png" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			toPublishHouse(){
				if(uni.getStorageSync("token") && uni.getStorageSync("userId") ){
					uni.navigateTo({
						url: '../publish/publish'
					})
				}else{
					this.getUserInfo()
				}
			},
			toApplyJob(){
				if(uni.getStorageSync("token") && uni.getStorageSync("userId") ){
					uni.navigateTo({
						url: '../publishApplyJob/publishApplyJob'
					})
				}else{
					this.getUserInfo()
				}
			},
			toZhaopin(){
				if(uni.getStorageSync("token") && uni.getStorageSync("userId") ){
					uni.navigateTo({
						url: '../publishZhaopin/publishZhaopin'
					})
				}else{
					this.getUserInfo()
				}
			},
			getUserInfo(){
				let that = this
			    uni.getUserProfile({
				   desc:'Wexin',     // 这个参数是必须的
				   success:res=>{
					   console.log(res)
					   uni.setStorageSync('nickName', res.userInfo.nickName);
					   uni.setStorageSync('avatarUrl', res.userInfo.avatarUrl);
					   uni.login({
					   	provider: 'weixin',
					   	success: (wxres => {
							console.log(wxres)
					   		that.$api.request('/api/web/wxlogin','',{
					   			code: wxres.code,
					   		}, failres => {
					   			uni.showToast({
					   				title: failres.msg,
					   				icon: "none"
					   			});
					   		}).then(res1 => {
					   			uni.setStorageSync('token', res1.data.token);
					   			uni.setStorageSync('openid', res1.data.openid);
								uni.setStorageSync('userId', res1.data.user.userId);
								// that.getStatus()
					   		})
					   	})
					   })
				   },
				   fail:err=>{
					   console.log(err)
					   uni.switchTab({
					   	url: "../home/home"
					   })
				   }
			   })
			},
		}
	}
</script>

<style lang="scss" scoped>
	.p_content{
		width: 100%;
		height: 100vh;
		background: #F5F5F5;
		.p_tips{
			font-size: 30rpx;
			color: #888888;
			padding: 30rpx;
		}
		.p_list{
			width: 100%;
			height: 120rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background: #FFFFFF;
			border-bottom: 1rpx solid #C8C7CC;
			.p_img{
				width: 80rpx;
				height: 80rpx;
				margin-left: 30rpx;
				margin-right: 30rpx;
			}
			.p_text{
				font-size: 32rpx;
			}
			.p_list_inner{
				display: flex;
				align-items: center;
			}
			.select_left{
				display: flex;
				align-items: center;
			}
			.to_arrow{
				width: 30rpx;
				height: 30rpx;
				margin-right: 30rpx;
			}
		}
	}
	
</style>
